package com.tianqu.tms.core.exception;


import java.util.List;

import org.apache.struts.action.ActionMessage;

/**
 * Tms 异常处理类
 */

public class TmsException extends Exception {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/** DB相关错误ID*/
	public final static String DB_TXCRROR = "S0002";
	public final static String SYS_IOEXCEPTION = "S0001";
	public final static String SYS_EXCEPTION = "S0000";
	public final static String PERMISSION_EXCEPTION = "U0003";
	public final static String TOKEN_EXCEPTION = "U0000";

	private String exceptionId = null;
	private Exception e  = null;
	private String[] errorParaArray = null;
	private List<ActionMessage> listActionErrors = null;
	
	protected TmsException() {
		super();
	}
	/**
	 * 
	 * @param listErrors
	 */
	public TmsException(List<ActionMessage> listErrors) {
		super();
		this.listActionErrors = listErrors;
	}
	/**
	 * 
	 * @param exceptionId
	 */
	public TmsException(String exceptionId) {
		super(exceptionId);
		this.exceptionId = exceptionId;
	}

	/**
	 * 
	 * @param exceptionId
	 * @param e
	 */
	public TmsException(String exceptionId, Exception e) {
		super(e);
		this.exceptionId = exceptionId;
		this.setException(e);
	}

	/**
	 * 
	 * @param exceptionId
	 * @param errorParam
	 */
	public TmsException(String exceptionId, String errorParam) {
		this.exceptionId = exceptionId;
		this.errorParaArray = new String[] { errorParam };
	}

	/**
	 * 
	 * @param exceptionId
	 * @param errorParam
	 * @param e
	 */
	public TmsException(String exceptionId, String errorParam, Exception e) {
		super(e);
		this.exceptionId = exceptionId;
		this.setException(e);
		this.errorParaArray = new String[] { errorParam };
	}
	/**
	 * 
	 * @param exceptionId
	 * @param errorParamArray
	 */
	public TmsException(String exceptionId, String[] errorParamArray) {
		this.exceptionId = exceptionId;
		this.errorParaArray = errorParamArray;
	}
	/**
	 * 
	 * @param exceptionId
	 * @param errorParamArray
	 * @param e
	 */
	public TmsException(String exceptionId, String[] errorParamArray,
			Exception e) {
		super(e);
		this.exceptionId = exceptionId;
		this.setException(e);
		this.errorParaArray = errorParamArray;
	}
	/**
	 * 
	 * @return
	 */
	public String[] getErrorParams() {
		return this.errorParaArray;
	}
	/**
	 * 
	 * @return
	 */
	public boolean isParamExist() {
		if (this.errorParaArray != null && this.errorParaArray.length > 0) {
			return true;
		} else {
			return false;
		}
	}
	/**
	 * 
	 * @return
	 */
	public String getExceptionId() {
		return exceptionId;
	}
	/**
	 * 
	 * @return
	 */
	public List<ActionMessage> getActionErrors(){
		return listActionErrors;
	}
	
	public void setException(Exception e) {
		this.e = e;
	}
	public Exception getException() {
		return e;
	}
}